package com.hldsmart.smartda.activity.home;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;

import com.hldsmart.smartda.R;
import com.hldsmart.smartda.utils.CustomRadioGroup;


public class SearchActivity extends Activity implements View.OnClickListener{
    private String[] label = {"亮黑色", "玫瑰金色", "玫瑰金色", "玫瑰金色", "玫瑰金色", "玫瑰感地方官地方官地方官党规党法大概金色", "玫瑰金色", "玫瑰金色", "玫瑰金色", "玫瑰金色", "玫瑰金色"};
    private String text1 = "";
    private TextView tv_cancel;
    private EditText et_search ;

    public static void startSearchActivity(Context context) {
        Intent intent = new Intent(context, SearchActivity.class);
        context.startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        //初始化控件
        initView();
        //初始化标签
        initexpression();

    }

    /**
     * 初始化标签
     */
    private void initexpression() {
        CustomRadioGroup customRadioGroup1 = (CustomRadioGroup) findViewById(R.id.customRadioGroup);
        setSpacing(customRadioGroup1,12,8);
        customRadioGroup1.setListener(new CustomRadioGroup.OnclickListener() {
            @Override
            public void OnText(String text) {
                text1 = text;

            }
        });

        for (int i = 0; i < label.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radiobutton_addcart, null);
            radioButton.setText(label[i]);
            customRadioGroup1.addView(radioButton);
        }
    }

    /**
     * 初始化控件
     */
    private void initView() {
         tv_cancel = (TextView) findViewById(R.id.tv_cancel);
         et_search = (EditText) findViewById(R.id.et_search);

        //设置点击事件
        tv_cancel.setOnClickListener(this);
        et_search.setOnClickListener(this);
    }
    private void setSpacing(CustomRadioGroup cg, int widthdp, int heightdp){
        cg.setHorizontalSpacing(widthdp);
        cg.setVerticalSpacing(heightdp);

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.et_search:
                break;
            case R.id.tv_cancel:
                this.finish();
                //android.os.Process.killProcess(android.os.Process.myPid());
                break;
        }
    }
}
